#include <iostream>
#include <vector>
#include <unordered_map>
using namespace std;
class Solution
{
public:
    bool checkAlmostEquivalent_2(string word1, string word2)
    {
        unordered_map<int, int> word1Map, word2Map;
        for (char w : word1)
            word1Map[w]++;
        for (char w : word2)
            word2Map[w]++;
        for (auto &[k, v] : word1Map)
        {
            if (abs(v - word2Map[k]) > 3)
                return false;
        }
        for (auto &[k, v] : word2Map)
        {
            if (abs(v - word1Map[k]) > 3)
                return false;
        }
        return true;
    }
    bool checkAlmostEquivalent(string word1, string word2)
    {
        int tmp1[26] = {0}, tmp2[26] = {0};
        for (auto &e : word1)
            tmp1[e - 'a']++;
        for (auto &e : word2)
            tmp2[e - 'a']++;

        for (int i = 0; i < 26; ++i)
            if (abs(tmp1[i] - tmp2[i]) > 3)
                return false;
        return true;
    }
};
int main()
{
    Solution s;
    return 0;
}